<script src="/docs/Chart.js"></script><!doctype html>
<html>
<head>
    <title>Easy-Monitor</title>
    <link href="/docs/styles.css" rel="stylesheet">
    <script src="/assets/jquery/jquery.min.js"></script>
    <script src="/docs/prettify.js"></script>
    <script src="/docs/Chart.js"></script>
    <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
</head>
<body>
<div class="redBorder"></div>
<div class="greenBorder"></div>
<div class="yellowBorder"></div>
<div id="wrapper">
    <nav>
        <dl>
        </dl>
    </nav>

    <div id="contentWrapper">
        <h1 id="mainHeader"><%- projectName %></h1>
        <h2 id="introText">Profiler Statistics By <a href="/">Easy-Monitor</a></h2>
        <%
        let dataLength = data.length;
        for(let i=0; i<dataLength; i++){

        %>
        <article id="<%- projectName %>">
        <p id="<%- data[i].processName %>::<%- data[i].processPid %>">
            <h1>Pid: <%- data[i].processPid %></h1>

            <h2>Functions ExecTime > <a href="/CPUProfiler/Project/<%- data[i].processName %>?timeout=<%- data[i].timeout %>"><%- data[i].timeout %>ms</a> List:</h2>
            <pre data-type="bash"><code>
                    <%
                    let longFunctions = data[i].data.longFunctions;
                    let longFunctionsLength = longFunctions.length;
                    for(let i=0; i<longFunctionsLength; i++){
                    %>
<%- (i+1) %>. FunctionName: "<%- longFunctions[i].funcName %>", ExecTime: "<%- longFunctions[i].execTime %>ms", FilePath: "<%- longFunctions[i].url %>"
                    <% } %>
            </code></pre>
            <p>
                You can set your timeout by add <code>"?timeout=your timeout&long_limit=your list number"</code> to this url, Here are some useful links:
            <ul>
                <li><a href="/CPUProfiler/Project/<%- data[i].processName %>?timeout=200">Set Functions Executing Time > 200ms</a></li>
                <li><a href="/CPUProfiler/Project/<%- data[i].processName %>?timeout=10&long_limit=10">Set Functions Executing Time > 10ms And List 10</a></li>
            </ul>
            </p>

            <h2>ExecTime Top <a href=""><%- data[i].data.topExecutingFunctions.length %></a> List:</h2>
            <pre data-type="bash"><code>
                    <%
                        let topExecutingFunctions = data[i].data.topExecutingFunctions;
                        let topExecutingFunctionsLength = topExecutingFunctions.length;
                    for(let i=0; i<topExecutingFunctionsLength; i++){
                    %>
<%- (i+1) %>. FunctionName: "<%- topExecutingFunctions[i].funcName %>", ExecTime: "<%- topExecutingFunctions[i].execTime %>ms", FilePath: "<%- topExecutingFunctions[i].url %>"
                    <% } %>
            </code></pre>
            <p>
                You can set your list number by add <code>"?top_limit=your list number"</code> to this url, Here are some useful links:
            <ul>
                <li><a href="/CPUProfiler/Project/<%- data[i].processName %>?top_limit=10">Set List Number = 10</a></li>
            </ul>
            </p>

            <h2>Top <a href=""><%- data[i].data.bailoutFunctions.length %></a> Bailout List:</h2>
            <pre data-type="bash"><code>
            <%
            let bailoutFunctions = data[i].data.bailoutFunctions;
            let bailoutFunctionsLength = bailoutFunctions.length;
            for(let i=0; i<bailoutFunctionsLength; i++ ){
            %>
<%- (i+1) %>. FunctionName: "<%- bailoutFunctions[i].funcName %>", BailoutReason: "<%- bailoutFunctions[i].bailoutReason %>", HitTimes:<%- bailoutFunctions[i].hitTimes %>, FilePath: "<%- bailoutFunctions[i].url %>"
            <% } %>
            </code></pre>
            <p>
                You can set your list number by add <code>"?bail_limit=your list number"</code> to this url, Here are some useful links:
            <ul>
                <li><a href="/CPUProfiler/Project/<%- data[i].processName %>?bail_limit=10">Set List Number = 10</a></li>
            </ul>
            </p>

        </article>
        <% } %>
    </div>
</div>
</body>
<script>
    $(document).ready(function(){

        var $nav = $("nav dl");

        $("article").each(function(){
            var $el = $(this);
            var $h1 = $el.find("h1");
            var sectionTitle = $h1.html();
            var articleId = $el.attr("id");
            var $dt = $("<dt><a href=\"#"+articleId +"\">"+sectionTitle+"</a></dt>");

            $dt.find("a").on("click",function(e){
                e.preventDefault();
                $('html,body').animate({scrollTop: $h1.offset().top},400);
            });

            $nav.append($dt);

            var $subtitles = $el.find("h2");

            $subtitles.each(function(){
                var $h2 = $(this);
                var title = $h2.text();
                var newID = articleId + "-" +camelCase(title);
                $h2.attr("id",newID);
                var $dd = $("<dd><a href=\"#" +newID + "\">" + title + "</a></dd>");

                $dd.find("a").on("click",function(e){
                    e.preventDefault();
                    $('html,body').animate({scrollTop: $h2.offset().top},400);
                })
                $nav.append($dd);

            });

            var $articles = $el.find("article");

        });

        $("canvas").each(function(){
            var $canvas = $(this);
            var ctx = this.getContext("2d");



            eval($("code[data-for='" + $canvas.attr("id") + "']").text());


            var evalString = "new Chart(ctx)." + $canvas.data("type") + "(data);";

            eval(evalString);

        });
        prettyPrint();

        function camelCase(str){
            var splitString = str.split(" ");

            var returnedCamel = splitString[0].toLowerCase();

            for (var i=1; i<splitString.length; i++){
                returnedCamel += splitString[i].charAt(0).toUpperCase() + splitString[i].substring(1).toLowerCase();
            }

            return returnedCamel;

        }
    });
</script>
</html>
